//
//  PayBookOrderSuccessController.m
//  KuWeiPark
//
//  Created by Kevin Su on 15/4/29.
//  Copyright (c) 2015年 Clief. All rights reserved.
//

#import "PayBookOrderSuccessController.h"
#import "WXApi.h"
#import "config.h"

@interface PayBookOrderSuccessController ()

@end

@implementation PayBookOrderSuccessController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.logoTopLayoutConstraint.constant = self.view.frame.size.height * 30 / 568.0;
    self.centerView.layer.masksToBounds = YES;
    self.centerView.layer.cornerRadius = 3;
    
    [self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hidesView)]];
}

- (void)hidesView{
    
    [self.view removeFromSuperview];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)checkInstalledWeixinClient{
    
    if (!([WXApi isWXAppInstalled] && [WXApi isWXAppSupportApi])){
        
        //如果不支持微信分享 提示错误
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"酷位停车提示" message:@"未安装微信" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alertView show];
    }
}

#pragma mark - IBActions

- (IBAction)clickWeixinAction:(id)sender {
    
    //分享微信
    [self checkInstalledWeixinClient];
    
    WXMediaMessage *message = [WXMediaMessage message];
    message.title = WEIXIN_SHARE_TITLE;
    message.description = WEIXIN_SHARE_CONTENT;
    [message setThumbImage:[UIImage imageNamed:@"share_logo"]];
    
    WXWebpageObject *ext = [WXWebpageObject object];
    ext.webpageUrl = WEIXIN_SHARE_LINK_URL;
    
    message.mediaObject = ext;
    
    SendMessageToWXReq* req = [[SendMessageToWXReq alloc] init];
    req.bText = NO;
    req.message = message;
    req.scene = WXSceneSession;
    
    [WXApi sendReq:req];
}

- (IBAction)clickPengyouquanAction:(id)sender {
    
    //分享朋友圈
    [self checkInstalledWeixinClient];
    
    WXMediaMessage *message = [WXMediaMessage message];
    message.title = WEIXIN_SHARE_TITLE;
    message.description = WEIXIN_SHARE_CONTENT;
    [message setThumbImage:[UIImage imageNamed:@"share_logo"]];
    
    WXWebpageObject *ext = [WXWebpageObject object];
    ext.webpageUrl = WEIXIN_SHARE_LINK_URL;
    
    message.mediaObject = ext;
    
    SendMessageToWXReq* req = [[SendMessageToWXReq alloc] init];
    req.bText = NO;
    req.message = message;
    req.scene = WXSceneTimeline;
    
    [WXApi sendReq:req];
}




@end
